/*
 *  Copyright (C) 2011 Hatsites
 * 
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.util.property;

import java.io.File;
import java.util.Properties;
import org.myorg.shr.gui.swg.util.property.PrpMgrAbs;

/**
 *
 * @author Hatsites
 *
 * email: Hatsites_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 */

public class PrpMgrhelpClass2id extends PrpMgrAbs {

    public PrpMgrhelpClass2id(){
        super(PrpMgrhelpClass2id._STR_NAMEFILE_);
    }
    public static void s_init() throws Exception{
        if (_INSTANCE_ == null) {
                _INSTANCE_ = new PrpMgrhelpClass2id();
        }
        PrpNamingEtk.s_init();
        try{
            PrpMgrhelpClass2id.read();
        }
        catch(Exception exc){
            PrpMgrhelpClass2id.write();

        }

        String strHlpCtn = _prp_.getProperty(PrpNamingEtk.STR_PRP_MIM_HELP_CONTENTS);
        String strGettingStarted = _prp_.getProperty(PrpNamingEtk.STR_PRP_MIM_HELP_GETTINGSTARTED);

        if (strHlpCtn == null){
            PrpMgrhelpClass2id._prp_.setProperty(PrpNamingEtk.STR_PRP_MIM_HELP_CONTENTS, "_welcome_");
            write();
        }
        if (strGettingStarted == null){
            PrpMgrhelpClass2id._prp_.setProperty(PrpNamingEtk.STR_PRP_MIM_HELP_GETTINGSTARTED, "_gsd_welcome_");
            write();
        }

        return;
    }

    public static void s_destroy(){
        PrpNamingEtk.s_destroy();
        if (_INSTANCE_ == null || PrpMgrhelpClass2id._prp_ == null){
            return;
        }
        PrpMgrhelpClass2id._prp_.clear();
        PrpMgrhelpClass2id._prp_ = null;
        _INSTANCE_ = null;

    }

    public static String getPrpGettingStarted() throws Exception{
        PrpMgrhelpClass2id.read();
        return _prp_.getProperty(PrpNamingEtk.STR_PRP_MIM_HELP_GETTINGSTARTED);
    }

    public static String getPrpContents() throws Exception {
        PrpMgrhelpClass2id.read();
        return _prp_.getProperty(PrpNamingEtk.STR_PRP_MIM_HELP_CONTENTS);
    }

    protected static void write() throws Exception{
        File fleFolderVersion = PrpMgrAbs.s_getOrCreateVersionDir();
        String strPathFile =
                fleFolderVersion.toString() +
                java.io.File.separator +
                PrpMgrhelpClass2id._STR_NAMEFILE_ +
                PrpMgrAbs._STR_FILEEXT_;
        PrpMgrAbs.write(_prp_, strPathFile );
        return;
    }

    protected static void read() throws Exception{
        File fleFolderVersion = PrpMgrAbs.s_getOrCreateVersionDir();
        String strPathFile =
                fleFolderVersion.toString() +
                java.io.File.separator +
                PrpMgrhelpClass2id._STR_NAMEFILE_ +
                PrpMgrAbs._STR_FILEEXT_;


        PrpMgrAbs.read(_prp_, strPathFile);
        return;
    }

    private static PrpMgrhelpClass2id _INSTANCE_;
    static private Properties _prp_ = new Properties();
    final static private String _STR_NAMEFILE_ = "helpClass2id";

}
